package com.example.infowall02.mapper;

import com.example.infowall02.domain.Admin;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AdminMapper {
    // 增
    @Insert("INSERT INTO admin (admin_name, admin_password,admin_email) VALUES (#{adminName}, #{adminPassword},#{adminEmail})")
    boolean insertAdmin(String adminName, String adminPassword, String adminEmail);
    // 查
    @Select("SELECT id, " +
            "admin_name AS adminName, " +
            "admin_password AS adminPassword ," +
            "admin_email AS adminEmail " +
            "FROM admin WHERE admin_name = #{adminName} " +
            "AND admin_password = #{adminPassword} " +
            "AND admin_email = #{adminEmail}")
    public Admin findAdminByUsernameAndPassword(String adminName, String adminPassword, String adminEmail);

    @Select("SELECT EXISTS (SELECT 1 FROM admin WHERE admin_name = #{adminName})")
    boolean existsByAdminName(String adminName);
}
